package service.impl;

import entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import repository.GoodsRepository;
import service.GoodsService;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsRepository goodsRepository;


    public Integer save(Object o) {
        Goods goods = (Goods) o;
        return goodsRepository.save(goods);
    }

    public List findAll() {
        return goodsRepository.findAll();
    }

    public void delete(Integer id) {
        goodsRepository.delete(id);
    }

    public Integer update(Object o) {
        Goods goods = (Goods) o;
        goodsRepository.saveOrUpdate(goods);
        return goods.getId();
    }
}
